﻿using Engine;
using Game;
using GameEntitySystem;

namespace SCIENEW
{
	public class UnloaderDevice : SixDirectionalDevice, IEntityDevice<ComponentUnloader>, IElectricElementDevice
	{
		public UnloaderDevice() : base("UnloaderDevice", 184, backSlot: 170, sideSlot: 170) { }
		public string GetEntityName(int value) => "Unloader";

		public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
		{
			return new BlockPlacementData { Value = DevicesBlockManager.GetDeviceValue(Id, DevicesUtils.GetDirectionXYZ(componentMiner, true)), CellFace = raycastResult.CellFace };
		}

		public Widget GetWidget(IInventory inventory, ComponentUnloader component) => new ChestNameWidget(inventory, component,"Unloader");

		public override DeviceBehavior[] GetBehaviors(Project project) => [new UnloaderDeviceBehavior(project)];

		public ElectricElement CreateElectricElement(SubsystemElectricity subsystemElectricity, int value, int x, int y, int z) => new UnloaderElectricElement(subsystemElectricity, new Point3(x, y, z));

		public ElectricConnectorType? GetConnectorType(SubsystemTerrain terrain, int value, int face, int connectorFace, int x, int y, int z) => ElectricConnectorType.Input;

		public int GetConnectionMask(int value) => int.MaxValue;

        public override int GetDisplayOrder(int value) => base.GetDisplayOrder(value) - 2;
	}
}